//
//  ByDocumentaryTitleCell.m
//  caipiao_ios
//
//  Created by mc on 2018/7/27.
//  Copyright © 2018年 ZhangZhanbin. All rights reserved.
//

#import "ByDocumentaryTitleCell.h"

@implementation ByDocumentaryTitleCell

+ (instancetype)cellWithTableView:(UITableView*)tableView{
    
    static NSString *cellIdentifier = @"ByDocumentaryTitleCell";
    ByDocumentaryTitleCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
    if (cell == nil) {
        cell = [[self alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
    }
    return cell;
}
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.selectionStyle = UITableViewCellSeparatorStyleNone;
        [self initViews];
    }
    return self;
}


- (void)initViews{
    [self.contentView.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)];
    
    
    UIImageView *iconView = [[UIImageView alloc] init];
    [self.contentView addSubview:iconView];
    [iconView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView).offset(10);
        make.centerY.equalTo(self.contentView).offset(0);
        make.size.mas_equalTo(CGSizeMake(50, 50));
    }];
    iconView.backgroundColor = BY_THEME_COLOR;
    iconView.layer.cornerRadius = 25;
    
    UILabel *nickLabel = [[UILabel alloc] init];
    [self.contentView addSubview:nickLabel];
    [nickLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(iconView.mas_right).offset(10);
        make.top.equalTo(iconView.mas_top).offset(5);
        make.size.mas_equalTo(CGSizeMake(70, 20));
    }];
    nickLabel.text = @"翻滚的咸鱼";
    nickLabel.textColor = [UIColor blackColor];
    nickLabel.font = FONT(12);
    
    UILabel *yieldLabel = [[UILabel alloc] init];
    [self.contentView addSubview:yieldLabel];
    [yieldLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.contentView).offset(-10);
        make.top.equalTo(nickLabel.mas_top).offset(0);
        make.size.mas_equalTo(CGSizeMake(40, 20));
    }];
    yieldLabel.font = FONT(12);
    yieldLabel.text = @"200%";
    yieldLabel.textColor = BY_THEME_COLOR;
    yieldLabel.textAlignment = NSTextAlignmentRight;
    
    UILabel *notesLabel = [[UILabel alloc] init];
    [self.contentView addSubview:notesLabel];
    [notesLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(yieldLabel.mas_right).offset(0);
        make.top.equalTo(yieldLabel.mas_bottom).offset(5);
        make.size.mas_equalTo(CGSizeMake(50, 15));
    }];
    notesLabel.font = FONT(12);
    notesLabel.text = @"预计回报";
    notesLabel.textColor = [UIColor lightGrayColor];
    notesLabel.textAlignment = NSTextAlignmentRight;
    
    
    UILabel *moneyLabel = [[UILabel alloc] init];
    [self.contentView addSubview:moneyLabel];
    [moneyLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(nickLabel.mas_left).offset(0);
        make.top.equalTo(notesLabel.mas_top).offset(0);
        make.right.equalTo(notesLabel.mas_left).offset(-10);
    }];
    moneyLabel.font = FONT(12);
    moneyLabel.text = @"累计中奖100000元";
    moneyLabel.textColor = [UIColor lightGrayColor];
    self.iconView = iconView;
    self.nickLabel = nickLabel;
    self.yieldLabel = yieldLabel;
    self.moneyLabel = moneyLabel;
    
}

@end
